package com.gistmap.ntdc.persistence.domain;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.util.Date;
import java.util.List;

/**
 * @author zhangran
 * @date 2018/12/20
 */
@Getter
@Setter
@Entity
@Table(name = "merchant_order")
@EntityListeners(AuditingEntityListener.class)
public class MerchantOrder {

    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private Long id;

    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "user_id")
    private User user;

    private String info;

    private String longitude;

    private String latitude;

    private Integer amount;

    /**
     * 收货人姓名
     */
    private String recipientName;

    /**
     * 收货地址
     */
    private String recipientAddress;

    /**
     * 收货人手机号
     */
    private String recipientMobile;

    @Enumerated(EnumType.STRING)
    private MerchantOrderStatus status;

    private Date paymentTime;

    @LastModifiedDate
    private Date updatedTime;

    @CreatedDate
    private Date createdTime;

    @JsonIgnore
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "merchantOrder")
    private List<MerchantOrderDetail> details;

}
